#include <stdlib.h>
#include <stdio.h>

#include "list.h"

#define TEST_SIZE 1024

int main( int argc, char** argv)
{
    struct queue A;
    initQueue( &A);
    
    int tmp;
    
    int i;
    for ( i = 1; i < TEST_SIZE ; i++)
    {
        if ( !addElem( &A , i))
        {
            printf("Queue is full");
        }
    }
    
    for ( i = 1; i < TEST_SIZE + 2; i++)
    {
        if ( getElem( &A, &tmp))
        {
            if ( i != tmp)
            {
                printf("Elem[ %d] = %d\n, but should be %d",i,tmp,i);
                printf("\n!!!TEST FAILED\n");
                return 0;
            }
        }
        else
        {   
            if ( (A.size == 0) && (A.first == A.last) && ( A.first == NULL)  )
            {
                //printf("Queue is empty\n");
            }
            else
            {
                printf("Queue isn't empy, but getElem have returned false");
                printf("\n!!!TEST FAILED\n");
                return 0;
            }
        }
    }
    
    delQueue( &A);
    if ( (A.size == 0) && (A.first == A.last) && ( A.first == NULL)  )
    {
    }
    else
    {
        printf("Queue isn't empty after delQueue");
        printf("\n!!!TEST FAILED\n");
        return 0;
    }
    
    printf("\n!!!TEST PASSED\n");
    return 0;
}